﻿using System;
using System.Text;

namespace Easy.Shared.Algorithm
{
    public static class Base64Extensions
    {
        ///<summary>
        ///Base64加密
        ///</summary>
        ///<paramname="Message"></param>
        ///<returns></returns>
        public static string Base64Code(this string content, Encoding encoding)
        {
            byte[] bytes = encoding.GetBytes(content);

            return Convert.ToBase64String(bytes);
        }
        ///<summary>
        ///Base64解密
        ///</summary>
        ///<paramname="Message"></param>
        ///<returns></returns>
        public static string Base64Decode(this string contentBase64, Encoding encoding)
        {
            byte[] bytes = Convert.FromBase64String(contentBase64);

            return encoding.GetString(bytes);
        }
    }
}
